import {createRouter,createWebHistory} from 'vue-router'
import Layout from '@/views/layout/Layout.vue'

export const routes = [
    {
        path:'/',
        component:()=>import ('../views/login.vue')
    },
    {
        path:'/login',
        component:()=>import ('../views/login.vue')
    },
    
    {
        path:'/401',
        component:()=>import ('../views/errorPage/401.vue')
    },
    {
        path:'/404',
        component:()=>import ('../views/errorPage/404.vue')
    }
    , 
    //默认首页，只包含模板菜单，默认进入第一个授权菜单
    {
      path:'/index',
      component:Layout,
      hidden:true
  },
];
//各个菜单路由定义在这里
const asyncRoutes = [
   
      {
        path: '/systemSetting',
        component: Layout,
        redirect: 'noredirect',
        alwaysShow: true,
        name: 'systemSetting',
        meta: {
          title: '系统设置',
          icon: 'system'
        },
        children: [
          {
            path: 'role',
            component: () => import('@/views/system/role.vue'),
            name: 'role',
            meta: {
              perms: ['sys_role'],
              title: '角色管理',
              noCache: true
            }
          },
          {
            path: 'user',
            component: () => import('@/views/system/user.vue'),
            name: 'user',
            meta: {
              perms: ['sys_user'],
              title: '用户授权',
              noCache: true
            }
          },
        ]
      },
];

const router = createRouter({
    history:createWebHistory("/pc_site"),
    routes,
    scrollBehavior:()=>({
        left:0,
        top:0
    })
})

export {
    asyncRoutes
}

export default router;